import requests
import json
import zipfile
import os

# 获取当前工作目录的路径
path = os.getcwd()


# 获取书籍ID列表
def getBooksId():
    # 请求获取书籍信息的URL
    url = "http://reciteword.youdao.com/reciteword/v1/param?key=normalBooks&keyfrom=reciteword.1.5.12.android&vendor=xiaomi&mid=9&imei=CQlkYjRlZWEwYzZlYmRiYjkyCXVua25vd24%253D&screen=1080x1920&model=Mi_Note_3&version=1.5.12"
    # 解析返回的JSON数据，提取书籍列表
    bookList = json.loads(requests.get(url).text)["data"]["normalBooks"]["bookList"]
    BooksId = []
    # 遍历书籍列表，提取每本书的ID
    for book in bookList:
        BooksId.append(book["id"])
    return BooksId

def main():
    # 获取书籍ID列表
    BooksId = getBooksId()
    print(BooksId,"888888")

    # print(BooksId)
    # # 获取书籍下载链接
    # downlink = getBooksDownLink(BooksId)
    # print(downlink)
    #
    # # 下载每本书并解压
    # for book in downlink:
    #     downBook(book["title"], book["link"])

# 程序入口
if __name__ == '__main__':
    main()